// pages/order/order.js
import { apiGetOrdersList } from "../../service/api/order";

const statusToTextMap = {
  1: "待发货",
  2: "已发货",
  3: "已签收",
  4: "退款中",
  5: "退款完成"
}

Page({

  data: {
    orderList:[]
  },

  toDelivery(e) {
    const orderId = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: `../delivery/delivery?id=${orderId}`,
    })
  },

  onLoad(options) {
    apiGetOrdersList().then(res => {
      const orderLit = res?.data;
      orderLit.map(item => {
        item.status = statusToTextMap[item.status]
      })
      this.setData({
        orderList: res?.data
      })
    })
  },
})